package com.shijiwei.lifthelper.ui;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.shijiwei.lifthelper.R;
import com.shijiwei.lifthelper.bean.DBJoke;
import com.shijiwei.lifthelper.bean.JokeBean;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.activity_joke_info)
public class JokeInfoActivity extends AppCompatActivity {

    @ViewInject(R.id.iv_jokeinfo_close)
    private ImageView closeImage;
    @ViewInject(R.id.tv_jokeinfo_title)
    private TextView titleText;
    @ViewInject(R.id.tv_jokeinfo_body)
    private TextView bodyText;

    private JokeBean jokeBean;
    private DBJoke dbJoke;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_joke_info);
        x.view().inject(this);
        jokeBean = (JokeBean) getIntent().getSerializableExtra("joke");
        dbJoke = (DBJoke) getIntent().getSerializableExtra("dbjoke");
        if (jokeBean != null){
            titleText.setText(jokeBean.getTitle());
            bodyText.setText(jokeBean.getContent().replaceAll("&hellip;","."));
        } else if (dbJoke != null){
            titleText.setText(dbJoke.getTitle());
            bodyText.setText(dbJoke.getContent());
        }

    }

    @Event(value = {R.id.iv_jokeinfo_close})
    private void onImageClick(View v){
        switch (v.getId()){
            case R.id.iv_jokeinfo_close:
                finish();
                break;
        }
    }
}
